# -*- coding: utf-8 -*-


import sys

from PyQt5.QtWidgets import QWidget, QSizePolicy, QLabel, QPushButton
from PyQt5.QtWidgets import QSlider, QHBoxLayout, QVBoxLayout, QApplication, QMainWindow, QLineEdit
from PyQt5.QtCore import Qt, QVersionNumber, QSize, QMetaObject, QCoreApplication
from PyQt5.Qt import QT_VERSION_STR

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(400, 200)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth())
        Form.setSizePolicy(sizePolicy)
        Form.setFixedSize(QSize(270, 150))
        Form.setWindowFlags(Qt.WindowCloseButtonHint)
        # 设置窗口无边框
        # Form.setWindowFlags(Qt.FramelessWindowHint)
        Form.setStyleSheet(".QLineEdit {font: 75 '微软雅黑' 12pt;}"
                           ".QWidget {border-image: url('./static/player_background.png')}")
        

        # 几个部件组成的垂直布局
        self.verticalLayout = QVBoxLayout(Form)
        self.verticalLayout.setObjectName("verticalLayout")

        # 用户名称和用户名称输入框组成的水平布局
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setSpacing(10)
        self.horizontalLayout.setObjectName("horizontalLayout")

        # 用户名称标签
        self.label = QLabel(Form)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
        self.label.setSizePolicy(sizePolicy)
        self.label.setStyleSheet("font: 12pt \"微软雅黑\"; color: white;")
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)

        # 用户名称输入对话框
        self.lineEdit = QLineEdit(Form)
        self.lineEdit.setEnabled(True)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(30)
        sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
        self.lineEdit.setSizePolicy(sizePolicy)
        self.lineEdit.setMaximumSize(QSize(300, 30))
        self.lineEdit.setBaseSize(QSize(130, 30))
        self.lineEdit.setObjectName("lineEdit")
        self.horizontalLayout.addWidget(self.lineEdit)
        self.horizontalLayout.setStretch(0, 4)
        self.horizontalLayout.setStretch(1, 8)
        self.verticalLayout.addLayout(self.horizontalLayout)

        # 密码和密码输入框组成的水平布局
        self.horizontalLayout_2 = QHBoxLayout()
        self.horizontalLayout_2.setSpacing(10)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")

        # 密码标签
        self.label_2 = QLabel(Form)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
        self.label_2.setSizePolicy(sizePolicy)
        self.label_2.setStyleSheet("font: 12pt \"微软雅黑\"; color: white;")
        self.label_2.setObjectName("label_2")
        self.horizontalLayout_2.addWidget(self.label_2)

        # 密码输入框
        self.lineEdit_2 = QLineEdit(Form)
        self.lineEdit_2.setEnabled(True)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(30)
        sizePolicy.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth())
        self.lineEdit_2.setSizePolicy(sizePolicy)
        self.lineEdit_2.setMaximumSize(QSize(300, 30))
        self.lineEdit_2.setBaseSize(QSize(130, 30))
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.horizontalLayout_2.addWidget(self.lineEdit_2)
        self.horizontalLayout_2.setStretch(0, 4)
        self.horizontalLayout_2.setStretch(1, 8)
        self.verticalLayout.addLayout(self.horizontalLayout_2)

        # 确认密码和确认密码输入框组成的水平布局
        self.horizontalLayout_3 = QHBoxLayout()
        self.horizontalLayout_3.setSpacing(10)
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")

        # 确认密码标签
        self.label_3 = QLabel(Form)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
        self.label_3.setSizePolicy(sizePolicy)
        self.label_3.setStyleSheet("font: 12pt \"微软雅黑\"; color: white;")
        self.label_3.setObjectName("label_3")
        self.horizontalLayout_3.addWidget(self.label_3)

        # 确认密码标签输入框
        self.lineEdit_3 = QLineEdit(Form)
        self.lineEdit_3.setEnabled(True)
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(30)
        sizePolicy.setHeightForWidth(self.lineEdit_3.sizePolicy().hasHeightForWidth())
        self.lineEdit_3.setSizePolicy(sizePolicy)
        self.lineEdit_3.setMaximumSize(QSize(300, 30))
        self.lineEdit_3.setBaseSize(QSize(130, 30))
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.horizontalLayout_3.addWidget(self.lineEdit_3)
        self.horizontalLayout_3.setStretch(0, 4)
        self.horizontalLayout_3.setStretch(1, 8)
        self.label_3.hide()
        self.lineEdit_3.hide()
        self.verticalLayout.addLayout(self.horizontalLayout_3)
        
        # 登录按钮、注册按钮组成的水平布局
        self.horizontalLayout_4 = QHBoxLayout()
        self.horizontalLayout_4.setSpacing(110)
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")

        # 登录按钮
        self.pushButton = QPushButton(Form)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
        self.pushButton.setSizePolicy(sizePolicy)
        self.pushButton.setFixedSize(QSize(70, 30))
        self.pushButton.setStyleSheet("font: 12pt \"微软雅黑\";")
        self.pushButton.setObjectName("pushButton")
        self.horizontalLayout_4.addWidget(self.pushButton)

        # 注册按钮
        self.pushButton_2 = QPushButton(Form)
        sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())
        self.pushButton_2.setSizePolicy(sizePolicy)
        self.pushButton_2.setFixedSize(QSize(70, 30))
        self.pushButton_2.setStyleSheet("font: 12pt \"微软雅黑\";")
        self.pushButton_2.setObjectName("pushButton_2")
        self.horizontalLayout_4.addWidget(self.pushButton_2)
        self.verticalLayout.addLayout(self.horizontalLayout_4)

        # 信号与槽
        # 点击登录按钮，确认标签、确认密码标签输入框隐藏
        self.pushButton.clicked.connect(self.signInHide)
        # 点击登录按钮，确认标签、确认标签密码输入框出现
        self.pushButton_2.clicked.connect(self.signInShow)

        self.retranslateUi(Form)
        QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "用户登录"))
        self.label.setText(_translate("Form", "用        户"))
        self.label_2.setText(_translate("Form", "密        码"))
        self.label_3.setText(_translate("Form", "确认密码"))
        self.pushButton.setText(_translate("Form", "登  录"))
        self.pushButton_2.setText(_translate("Form", "注  册"))

    def signInShow(self):
        self.label_3.show()
        self.lineEdit_3.show()

    def signInHide(self):
        self.label_3.hide()
        self.lineEdit_3.hide()


if __name__ == "__main__":

    app = QApplication(sys.argv)
    mainWindow = Ui_Form()
    qMainWindow = QMainWindow()
    mainWindow.setupUi(qMainWindow)
    qMainWindow.show()
    sys.exit(app.exec_())
